//
//  VersionInformationVc.m
//  YZZX
//
//  Created by Easaa on 15/5/7.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "VersionInformationVc.h"



@interface VersionInformationVc ()<HXHttpRequestDelegate>
{
    HXHttpRequest   *_httpRequest;
}

@end

@implementation VersionInformationVc

- (void)viewDidLoad {
    [super viewDidLoad];

    self.iamgeview = [[UIImageView alloc]init];
    self.iamgeview.frame = CGRectMake(Dev_ScreenWidth/2-40, 20, 40, 40);
    [self.view addSubview:self.iamgeview];
    // self.iamgeview.image = [UIImage imageNamed:@"top_navgation@2x"];
    
    self.labletext = [[UILabel alloc]initWithFrame:CGRectMake(Dev_ScreenWidth/2, 20, 80, 40)];
    self.labletext.textAlignment = NSTextAlignmentCenter;
    self.labletext.font = [UIFont systemFontOfSize:14];
    // self.labletext.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.labletext];
    //  self.labletext.text = @"您好*妈妈";
    [self RequestHeadlLinesAndHeadImageDataFantion];
    
    
    
    
    
    NSString  * app_Version =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    app_Version = [NSString stringWithFormat:@"v%@",app_Version];
    
    UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(Dev_ScreenWidth/2+30, 60, 60, 30)];
    labelTitle.font = [UIFont boldSystemFontOfSize:11.0];  //UILabel的字体大小
    labelTitle.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
    labelTitle.textColor = [UIColor grayColor];
    labelTitle.textAlignment = NSTextAlignmentCenter;  //文本对齐方式
    //[labelTitle setBackgroundColor:[UIColor redColor]];
    labelTitle.text = app_Version;
    [self.view addSubview:labelTitle];

    
    
}




#pragma mark 请求大标题数据
-(void)RequestHeadlLinesAndHeadImageDataFantion
{
    
    //列表请求  参数为 用户ID  、 用户账号
    NSDictionary* dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
                               [XSZ_UICommon useridChangUaerdfLoginBoolString],                    @"user_id",
                               nil];
    
    
    
    if (_httpRequest == nil)
    {
        _httpRequest = [[HXHttpRequest alloc] init];
        _httpRequest.delegate = self;
        
        
        
    }
    [_httpRequest requestForParams:dicParams andMethod:YZ_WEBSITE_LIST andTag:1001];
    

    
}


#pragma mark Http request delegate
- (void)requestFinished:(NSString *)responseString andStatusCode:(int)statusCode andTag:(NSInteger)tag
{
    
    //tableview列表数据
    
    if(tag == 1001)
    {
        
        
        //NSLog(@"---------------->>>> %@",responseString);
        
        NSDictionary *DicJosn = [[NSDictionary alloc]init];
        DicJosn = [JsonUtil jsonToDic:responseString];
        
        //  NSLog(@"---------------->>>> \n%@",dic);
        
        
        NSString * strs = DicJosn[@"data"];
        NSDictionary *dicData =[JsonUtil jsonToDic:strs];
        
        
        NSArray *arryy =(NSArray *)dicData;
        
        
        
        // NSLog(@"---------00------->>>> %@",arryy);
        
        for (NSDictionary *dicModel in arryy) {
            
            // NSLog(@"------->>>> %@",[dicuu objectForKey:@"Image"]);
            
            WebsiteDataMoedel *cellmodel =[[WebsiteDataMoedel alloc]initWithDictionaryData:dicModel];
            [self.iamgeview sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.hellomommy.cn%@",cellmodel.image_url]] placeholderImage:[UIImage imageNamed:@"bg"]];
            
            [self.iamgeview sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.hellomommy.cn%@",cellmodel.image_url]]];
            
            [self.labletext setText:cellmodel.site_name];
            
        }
        
        //刷新
        // [TableviewMassge reloadData];

        
    }
}

- (void)requestFailed:(NSError *)error andTag:(NSInteger)tag
{

}

@end
